{extend name="./common/base" /}
{block name="body"}
<ul class="flow-default" id="baomingList">

</ul>
<script>
    layui.use('flow', function(){
        var flow = layui.flow;
        flow.load({
            elem: '#baomingList' //流加载容器
            ,scrollElem: '#baomingList' //滚动条所在元素，一般不用填，此处只是演示需要。
            ,done: function(page, next){ //执行下一页的回调
                var lis = [];
                $.get("{:addonUrl('getBmlist')}?page="+page,function (res) {
                    layui.each(res.data, function(index, item){
                        if(item.bm_id){
                            lis.push('<li class="vote_list"><div class="vote_pack"> <div class="vote_cover"> <div class="total_and_id">'+item.bm_id+'号 | '+item.vote_total+'票</div> <img src="'+item.cover+'"> <div class="vote_desc" style="background-color: {$info.text_color}"> <div class="vote_name">'+item.username+'</div> <a onclick="toVote('+item.bm_id+')" class="layui-btn baoming_btn"> <i class="layui-icon vote_icon">&#xe6c6;</i>投票 </a> <p class="vote_desc_content">'+item.description+'</p> </div> </div> </div> </li>');
                        }
                    });
                    next(lis.join(''), parseInt(res.current_page) < res.last_page);
                })

            }
        });
    });
    function toVote(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
                var index=layer.load(1)
                $.post("{:addonUrl('toVote')}",{'bm_id':id},function (res) {
                    layer.close(index);
                    if(res.status==-2){
                        layer.open({
                            type: 1,
                            title:'请先扫码',
                            skin: 'layui-layer-rim', //加上边框
                            area: ['170px', '200px'], //宽高
                            content: "<img width='150' height='150' src='{$mpInfo.qrcode}' >"
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                })
                return false;
        });
    }
</script>
{/block}